//
// Created by zhupi on 2024/11/2.
//

#include "edit_library_dialog_view_ctrl.h"
#include "view_edit_material_dialog_view_ctrl.h"
#include <QDebug>
MaterialDialogViewCtrl &MaterialDialogViewCtrl::GetIns() {
    static MaterialDialogViewCtrl ins;
    return ins;
}

void MaterialDialogViewCtrl::Initial(const QString &name, int parentId)
{
    qDebug() << " ============================ ";
    if (dialog_ != nullptr) {
        delete dialog_;
        dialog_ = nullptr;
    }
    dialog_ = new EditLibraryDialog(nullptr);
    dialog_->Initial();

    std::vector<std::vector<QString>> data = {
            {"89222", "SysLibrary", "Materials", "2000000siemens/m"},
            {"15", "SysLibrary", "Materials", "2000000siemens/m"},
            {"steel_1010", "SysLibrary", "Materials", "2000000siemens/m"},
    };
    dialog_->loadTableData(data);
    InitConect();
    dialog_->exec();
    dialog_ = nullptr;
}

void MaterialDialogViewCtrl::InitConect()
{
    connect(dialog_, &EditLibraryDialog::RowSelectedSg, &ViewEditMaterialDialogViewCtrl::GetIns(), &ViewEditMaterialDialogViewCtrl::Inital);
}
